<!DOCTYPE html>
<html>
	<head>
		<title>Datatable Validation. Complex Rule. </title>
		<link rel="stylesheet" href="../../../codebase/webix.css" type="text/css" charset="utf-8">
		<script src="../../../codebase/webix.js" type="text/javascript" charset="utf-8"></script>
		
		<link rel="stylesheet" type="text/css" href="../common/samples.css">
		<script src="../common/testdata.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div class='header_comment'>Cell validation</div>
		<div class='sample_comment'>Rank and Votes columns must contain positive numbers</div>
		<div id="testA"></div>
		<hr>
		<div id="testB" class='sample_comment'></div>
		<script type="text/javascript" charset="utf-8">

		function positiveNumber(obj){
			return obj.votes > 0 && obj.rank > 0;
		}
		

		webix.ready(function(){
			grid = webix.ui({
				container:"testA",
				view:"datatable",
				columns:[
					{ id:"rank",	header:"", css:"rank",	width:50,	editor:"text"},
					{ id:"title",	header:"Film title",	width:200,	editor:"text"},
					{ id:"year",	header:"Released" , 	width:80,	editor:"text"},
					{ id:"votes",	header:"Votes", 		width:100,	editor:"text"}
				],
				rules:{
					$obj:positiveNumber
				},
				editable:true,
				autoheight:true,
				autowidth:true,

				data:small_wrong_film_set,
				ready:function(){
					this.validate();
				}
			});		
		});
		</script>

		<input type="button" value="Add row" onclick="grid.add({ rank:-1 })">
	</body>
</html>